using System.ComponentModel;

namespace Test.ConsoleProgram.Algorithm.Interview
{
    [TestDescriptionAttribute("面试题 0046. 把数字翻译成字符串")]
    public class No0046_TranslateNum : AbsBaseTestItem
    {
        public override void OnTest()
        {
            Assert.TestExe(TranslateNum, 12258, 5);
        }

        public int TranslateNum(int num)
        {
            string src = num.ToString();
            int p = 0, q = 0, r = 1;
            for (int i = 0; i < src.Length; i++)
            {
                p = q;
                q = r;
                r = 0;
                r += q;
                if (i == 0)
                {
                    continue;
                }
                string pre = src.Substring(i - 1, 2);
                if (pre.CompareTo("25") <= 0 && pre.CompareTo("10") >= 0)
                {
                    r += p;
                }
            }
            return r;
        }
    }
}
